<template>
  <div class="divBox">
    <el-card class="box-card">
      <!-- <div slot="header" class="clearfix">
        <div class="container">
          <el-form label-width="100px" :inline="true">
            <el-form-item>
               <el-select v-model="tableFrom.status" clearable  placeholder="请选择">
                <el-option
                  v-for="item in statusOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-date-picker v-model="dateLimit" value-format="yyyy-MM-dd" format="yyyy-MM-dd" size="small" type="daterange" placement="bottom-end" placeholder="自定义时间" style="width: 220px;" @change="onchangeTime" />
            </el-form-item>
            <el-form-item>
              <el-input v-model="tableFrom.batchNo" placeholder="请输入批次号" class="selWidth" size="small" clearable />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="getList(1)" size="small">查询</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div> -->
      <el-table
        v-loading="listLoading"
        :data="tableData.data"
        style="width: 100%"
        size="mini"
        class="table"
        highlight-current-row
      >
        <el-table-column
          prop="id"
          label="ID"
          width="80"
        />
        <el-table-column
          prop="batchNo"
          label="批次号"
          width="150"
        />
        <el-table-column
          prop="batchName"
          label="批次名称"
          width="150"
        />
        <el-table-column
          prop="totalAmount"
          label="金额"
          min-width="150"
        />
        <el-table-column
          label="总数量"
          min-width="100"
          prop="totalNum"
        />
        <!-- <el-table-column label="销售总额" min-width="150">
          <template slot-scope="scope">
            <span :class="scope.row.type == 1 ? 'color_red': 'color_green'">{{scope.row.type == 1 ? '+' : '-' }}{{scope.row.price}}</span>
          </template>
        </el-table-column> -->
        <el-table-column label="通知时间" min-width="130" prop="notifyTime">
        </el-table-column>
        <el-table-column label="创建时间" min-width="130" prop="createTime">
        </el-table-column>
        <el-table-column label="更新时间" min-width="130" prop="updateTime">
        </el-table-column>
        <el-table-column label="操作" min-width="150" fixed="right" align="center"> 
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="showDetail(scope.row)" class="mr10" v-hasPermi="['admin:system:user:level:update']">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
       <!--记录-->
       <el-dialog
        title="提现记录"
        :visible.sync="dialogVisible"
        width="1000px"
      >
        <!-- <div class="container">
          <el-form label-width="100px" :inline="true">
            <el-form-item>
              <el-date-picker v-model="tableFromLog.dateLimit" value-format="yyyy-MM-dd" format="yyyy-MM-dd" size="small" type="daterange" placement="bottom-end" placeholder="自定义时间" style="width: 220px;" @change="onchangeTime" />
            </el-form-item> -->
            <!-- <el-form-item>
              <el-input v-model.number="tableFromLog.batchId" placeholder="请输入批次号" class="selWidth" size="small" clearable />
            </el-form-item> -->
            <!-- <el-form-item>
              <el-input v-model="tableFromLog.realName" placeholder="请输入姓名" class="selWidth" size="small" clearable />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="getDetailList(1)" size="small">查询</el-button>
            </el-form-item>
          </el-form>
        </div> -->
      <el-table
        v-loading="LogLoading"
        border
        :data="tableDataLog.data"
        style="width: 100%"
      >
        <el-table-column
          prop="id"
          align="center"
          label="ID"
          min-width="80"
        />
        <el-table-column
          prop="designerId"
          label="设计师ID"
          align="center"
          min-width="100"
        />
        <el-table-column
          prop="realName"
          label="用户名"
          align="center"
          min-width="100"
        />
        <el-table-column
          prop="remark"
          label="备注"
          align="center"
          min-width="280"
        />
        <el-table-column
          prop="status"
          label="状态"
          align="center"
          min-width="100"
        >

          <template slot-scope="scope">
            <span>{{scope.row.status == 'WAIT_ACCEPT' ? '待受理' : '' }}</span>
            <span>{{scope.row.status == 'ACCEPTED' ? '已受理' : '' }}</span>
            <span>{{scope.row.status == 'PROCESSING' ? '转账中' : '' }}</span>
            <span>{{scope.row.status == 'FINISHED' ? '已完成' : '' }}</span>
            <span>{{scope.row.status == 'CLOSED' ? '已关闭' : '' }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="操作时间"
          align="center"
          min-width="280"
        />
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[10, 20, 30, 40]"
          :page-size="tableFromLog.limit"
          :current-page="tableFromLog.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableDataLog.total"
          @size-change="handleSizeChangeLog"
          @current-change="pageChangeLog"
        />
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { withdrawBatchListApi, withdrawItemListApi } from '@/api/designer'
  export default {
    name: 'DesignerWithdraw',
    data() {
      return {
        dateLimit: [],
        tableData: {
          data: [],
          total: 0
        },
        listLoading: true,
        tableFrom: {
          // status:'',
          // dateLimit: '',
          // batchNo: '',
          page: 1,
          limit: 20
        },
        statusOptions:[
          { value: 'WAIT_ACCEPT', label: '待受理'},
          { value: 'ACCEPTED', label: '已受理'},
          { value: 'PROCESSING', label: '转账中'},
          { value: 'FINISHED', label: '已完成'},
          { value: 'CLOSED', label: '已关闭'},
        ],
        tableFromLog: {
          page: 1,
          limit: 10,
          // dateLimit: '',
          batchId: '',
          // realName: ''
        },
        tableDataLog: {
          data: [],
          total: 0
        },
        dialogVisible: false,
        LogLoading: false,
      }
    },
    mounted() {
      // this.getTypes()
      this.getList()
    },
    methods: {
      // 列表
      getList(num) {
        this.listLoading = true
        this.tableFrom.page = num ? num : this.tableFrom.page;
        withdrawBatchListApi(this.tableFrom).then(res => {
          this.tableData.data = res.list
          this.tableData.total = res.total
          this.listLoading = false
        }).catch((res) => {
          this.listLoading = false
        })
      },
      pageChange(page) {
        this.tableFrom.page = page
        this.getList()
      },
      handleSizeChange(val) {
        this.tableFrom.limit = val
        this.getList()
      },
      // 具体日期
      onchangeTime (e) {
        this.dateLimit = e;
        this.tableFrom.dateLimit = e ? this.dateLimit.join(',') : ''
        this.tableFrom.page = 1
        this.getList();
      },
      handleClose() {
        this.dialogVisible = false;
      },
      // 详情
      showDetail(row) {
        this.tableFromLog.batchId = row.id
        this.dialogVisible = true
        this.onWithdrawLog()
      },
      // 提现记录详情
      onWithdrawLog() {
        this.dialogVisible = true
        this.LogLoading = true
        withdrawItemListApi( this.tableFromLog ).then(res => {
          this.tableDataLog.data = res.list
          this.tableDataLog.total = res.total
          this.LogLoading = false
        }).catch(() => {
          this.LogLoading = false
        })
      },
      handleSizeChangeLog(val) {
        this.tableFromLog.limit = val
        this.onWithdrawLog()
      },
      pageChangeLog(page) {
        this.tableFromLog.page = page
        this.onWithdrawLog()
      },
      getDetailList(num) {
        this.LogLoading = true
        this.tableFromLog.page = num ? num : this.tableFromLog.page;
        withdrawItemListApi(this.tableFromLog).then(res => {
          this.tableDataLog.data = res.list
          this.tableDataLog.total = res.total
          this.LogLoading = false
        }).catch((res) => {
          this.LogLoading = false
        })
      },
    }
  }
</script>

<style scoped lang="scss">
  .dashboard-workplace {
    &-header {
      &-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        margin-right: 16px;
        font-weight: 600;
      }

      &-tip {
        width: 82%;
        display: inline-block;
        vertical-align: middle;
        margin-top: -12px;
        &-title {
          font-size: 13px;
          color: #000000;
          margin-bottom: 12px;
        }

        &-desc {
          width: 100%;
          &-sp {
            width: 32%;
            color: #17233D;
            font-size: 13px;
            display: inline-block;
            line-height: 25px;
          }
        }
      }

      &-extra {
        .ivu-col {
          p {
            text-align: right;
          }

          p:first-child {
            span:first-child {
              margin-right: 4px;
            }

            span:last-child {
              color: #808695;
            }
          }

          p:last-child {
            font-size: 22px;
          }
        }
      }
    }
  }
  .selWidth{
    width: 300px;
  }
  .color_red{
    color:#F5222D;
  }
  .color_green{
    color:#7ABE5C;
  }
</style>
